package com.link.database.service.impl;

import com.link.database.dao.DBChannelDao;
import com.link.database.entity.DBChannel;
import com.link.database.service.DBChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DBChannelServiceImpl implements DBChannelService {
    @Autowired
    private DBChannelDao dbChannelDao;

    @Override
    public int addChannel(DBChannel dbChannel) {
        return dbChannelDao.insert(dbChannel);
    }

    @Override
    public int updateChannel(DBChannel dbChannel) {
        return dbChannelDao.update(dbChannel);
    }

    @Override
    public int deleteChannel(long id) {
        return dbChannelDao.deleteById(id);
    }

    @Override
    public DBChannel getChannelById(long id) {
        return dbChannelDao.selectById(id);
    }

    @Override
    public List<DBChannel> getAllChannels() {
        return dbChannelDao.selectAll();
    }

    @Override
    public List<DBChannel> getChannelsByRegionId(long regionId) {
        return dbChannelDao.selectByRegionId(regionId);
    }
}